define('utils/Storage', null, function(){

var Storage = function() {
    this.local = localStorage;

    this.sep = '|||';
};
Storage.prototype = {
    constructor: Storage,

    /**
     * 设置值
     *
     * @param {String} name
     * @param {String} value
     * @param {Number} expires 过期时间节点的时间戳 毫秒 0 表示不限时间
     */
    set: function(name, value, expires) {
        if(undefined === expires) {
            expires = 0;
        }

        var ret = encodeURIComponent(value) + this.sep + expires;

        this.local.setItem(name, ret);
    },

    /**
     * 获取值
     *
     * @param {String} name
     * @return {String | null}
     */
    get: function(name) {
        var ret = this.local.getItem(name);

        if(null === ret) {
            return null;
        }

        var index = ret.indexOf(this.sep);
        var time = ret.substring(index + this.sep.length);
        var now = new Date().getTime();

        if(now > time) {
            this.local.removeItem(name);

            return null;
        }

        return decodeURIComponent(ret.substring(0, index));
    },

    delete: function(key) {
        this.local.removeItem(key);
    }
};

return Storage;
});
